package com.cunshe.service;

import com.cunshe.dao.DataDownDao;
import com.cunshe.domain.DataDown;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * 资料下载
 * @author xiao
 */
@Service
public class DataDownService {

    @Autowired
    private DataDownDao dataDownDao;

    /** 新增 */
    @Transactional(rollbackFor = Exception.class)
    public int insert(DataDown record) {
        record.setCreatetime(new Date());
        return dataDownDao.insert(record);
    }

    /** 删除 */
    @Transactional(rollbackFor = Exception.class)
    public int delete(Long id) {
        return dataDownDao.delete(id);
    }

    /** 修改 */
    @Transactional(rollbackFor = Exception.class)
    public int update(DataDown record){
        record.setUpdatetime(new Date());
        return dataDownDao.update(record);
    }

    /** 查询列表 */
    public List<DataDown> all() {
        return list(DataDown.builder().build());
    }

    /** 查询列表 */
    public List<DataDown> list(DataDown record) {
        return dataDownDao.list(record);
    }

}